#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
__author-default__ = 'Pup--->>WX_l599p22'
__cttime-default__ = '20170721'
'''

# import pymysql
#
# def get_conn():
# 	try:
# 		conn = pymysql.connect(host='192.168.0.12',port=3306,user='root',passwd='@root521',db='test',charset='utf8')
# 		return conn
# 	except Exception,e:
# 		print e
#
# class User(object):
# 	def __init__(self,id,name):
# 		self.id = id
# 		self.name = name
#
# 	@staticmethod
# 	def create():
# 		conn = get_conn()
# 		cur = conn.cursor()
#
# 		sql = 'create table if not EXISTS user001 (id int not null primary key,' \
# 			  'name varchar(25) not null)'
# 		cur.execute(sql)
# 		conn.commit()
# 		cur.close()
# 		conn.close()
#
# 	def save(self):
# 		conn = get_conn()
# 		cur = conn.cursor()
#
# 		sql = 'insert into user001(id,name) VALUES ("%s","%s")'
# 		cur.execute(sql,(self.id,self.name))
# 		conn.commit()
# 		cur.close()
# 		conn.close()
#
# 	@staticmethod
# 	def query_all():
# 		conn = get_conn()
# 		cur = conn.cursor()
#
# 		sql = 'select * from user001'
# 		cur.execute(sql)
# 		rows = cur.fetchall()
# 		users = []
# 		for row in rows:
# 			user = User(row[0],row[1])
# 			users.append(user)
# 		conn.commit()
# 		cur.close()
# 		conn.close()
# 		return users
#
# 	def __str__(self):
# 		return 'id:{}---name:{}'.format(self.id,self.name)
#
from app import db

class User(db.Model):
	__tablename__ = 'user003'
	id = db.Column(db.Integer,primary_key=True)
	name = db.Column(db.String(25))

	def __init__(self,id,name):
		self.id = id
		self.name = name

	def __str__(self):
		return 'id:{}---name:{}'.format(self.id,self.name)
